package gdut.jmxywz.action;

import gdut.jmxywz.been.Bookmaking;
import gdut.jmxywz.been.Dissertation;
import gdut.jmxywz.been.Horizontal;
import gdut.jmxywz.been.ImageInfo;
import gdut.jmxywz.been.Info;
import gdut.jmxywz.been.MessageBoard;
import gdut.jmxywz.been.Prize;
import gdut.jmxywz.been.StmessageBoard;
import gdut.jmxywz.been.StmessageReply;
import gdut.jmxywz.been.TableFiles;
import gdut.jmxywz.been.TeachingFiles;
import gdut.jmxywz.been.Vertical;
import gdut.jmxywz.util.PageModel;

import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts2.ServletActionContext;

@SuppressWarnings("serial")
public class StaticHtmlAction extends BaseAction {
	
	 private int id;
	 private String infoType;
	 //1： infoType="affiche";2：infoType="news";3：infoType="scientific";4：infoType="dynamic";5: infoType="studentAffairs"; 6：infoType="tableFiles";7：infoType="teachingFiles";
	 //8:
     private String auditState;
     private String auditType;
     
	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public String getInfoType() {
		return infoType;
	}

	public void setInfoType(String infoType) {
		this.infoType = infoType;
	}

	public String getAuditState(){
		return auditState;
	}

	public void setAuditState(String auditState){
		this.auditState = auditState;
	}
	
	public String getAuditType(){
		return auditType;
	}

	public void setAuditType(String auditType){
		this.auditType = auditType;
	}

	public void change(){
		System.out.println("----------------------"+infoType);
		if("1".equals(this.infoType)){
			   //通知公告
			   this.infoType="affiche";
			   
		   }else if("2".equals(this.infoType)){
			   //学院新闻
			   this.infoType="news";
		   }
		   else if("3".equals(this.infoType)){
			   //科研信息
			   this.infoType="scientific";
		   }
		   else if("4".equals(this.infoType)){
			   //科研动态
			   this.infoType="dynamic";
			   
		   }else if("5".equals(this.infoType)){
			   //学生党建工作
			   this.infoType="parttyconstructionstudentAffairs";
		   }else if("9".equals(this.infoType)){
			   //院学生会工作
			   this.infoType="studentunionstudentAffairs";
		   }
		   else if("10".equals(this.infoType)){
			   //院团委工作
			   this.infoType="youncommitmentstudentAffairs";
		   }
		   else if("11".equals(this.infoType)){
			   //心悦心理协会工作
			   this.infoType="mentalystudentAffairs";
		   }
		   else if("12".equals(this.infoType)){
			   //毕业生通知工作
			   this.infoType="granduatestudentAffairs";
		   }else if("13".equals(this.infoType)){
			   //就业资讯工作
			   this.infoType="jobstudentAffairs";
		   }else if("6".equals(this.infoType)){
			   
			   //表格下载
			   this.infoType="tableFiles";
			   
		   }else if("7".equals(this.infoType)){
			   //教学资源下载
			   this.infoType="teachingFiles";
		   }
	}
	
	
	/***
	 *  //Info静态化
	 * @return
	 * @throws Exception
	 */
	
	public String InfoDetailHtml() throws Exception{
		
		   ServletContext  context = ServletActionContext.getServletContext();
		  
		   String fileHql="";
		   String hqlList="";
		   //转换
		   this.change();
		   
		   //返回类型
		   String returnType = infoType+"DetailHtml";
		   
		   if("tableFiles".equals(infoType)||"teachingFiles".equals(infoType)){
			  if("1".equals(auditType))
			   {
				   if("tableFiles".equals(infoType)){
					   fileHql="from tableFiles where tableId = "+id;
					   
					   hqlList ="from TableFiles where auditing = 1  order by uploadTime desc , tableId desc";
					   
				   }else{
					   fileHql="from TeachingFiles where teachSrcId = "+id;
					   
					   hqlList ="from TeachingFiles where auditing = 1  order by uploadTime desc , teachSrcId desc";
				   }
			   }else{
				   
				   return  returnType;
			   }
		   }else{
			    fileHql="from InfoFiles where infoId = "+id;
			   
			    hqlList ="from Info where auditing = 2 and infoType in(select inf.infoType from Info inf where inf.infoId="+id+") "+ "order by infoTime desc , infoId desc";
		   }
		   
		   
		   
		   //创建单个静态化文件
		   this.createInfoDetail(context, id, fileHql);
		  
	    	 
	       //生成静态化消息列表----分页生成显示多个html文件,每个10条
	    	 
	       this.createInfoListHtml(context, hqlList,"",20);
	       
//	       //生成滚动新闻,显示5张图片
//			if("news".equals(infoType)){
//				
//				infoType="scrollNews";
//				
//				String scrollNews="from ImageInfo img where img.info.infoId in(select inf.infoId from Info inf where inf.auditing =2)"+" order by imageId desc";
//				
////				//列表more
//				this.createInfoListHtml(context, scrollNews, "", 5);
////				//主页
////				this.createInfoIndex(context, scrollNews, 5);
//				
//				infoType="news";
//			}
			
	        /////静态化首页
			this.creatIndex(context, 8);
			
		   returnType = infoType+"DetailHtml";
		   
		   return  returnType;
	}
	
	/***
	 *  //删除静态化文件
	 * @return
	 * @throws Exception
	 */
	public String DeleteInfoDetailHtml() throws Exception{
		
		   ServletContext  context = ServletActionContext.getServletContext();
		   //转换		
   	 	  
		   String fileHql="from InfoFiles where infoId = "+id;
		   String hqlList="";
		   String hqlOld="";
		   
  	       System.out.println("----------删除静态化文件----------");
  	       System.out.println("------infoType-------"+infoType);
  	  

		   if("6".equals(infoType)||"7".equals(infoType)){
				   if("6".equals(infoType)){
					   hqlList ="from TableFiles where auditing = 1 and tableId !=" +id;
					   
					   hqlOld="from TableFiles where auditing = 1 " ;
					   
				   }else{
					   hqlList ="from TeachingFiles where auditing = 1 and teachSrcId !=" +id;
					   
					   hqlOld="from TeachingFiles where auditing = 1 ";
					   
				   }
		   }else{
			    hqlList ="from Info where auditing = 2 and infoId !=" +id+" and infoType= "+infoType ;
			   
			    hqlOld="from Info where auditing = 2  and infoType= "+infoType;
		   }
		   this.change();
		   
		   List  infoFiles = this.getCommonService().findListByHql(fileHql, null);
	 	   
		   
		    System.out.println("---"+context.getRealPath("/"));
			
			String path ="htmlPage"+"/"+infoType+"/"+infoType+id+".html";
			
			if(this.getCommonService().fileExist(path)){
				
				//删除静态化文件，
				this.getCommonService().fileDelete(path);
				
				System.out.println("已删除staticHtml---"+path);
			}
			
	    	 //生成静态化消息列表----分页生成显示多个html文件,每页10条
			System.out.println("----"+hqlList);
			System.out.println("----"+hqlOld);
	    	this.createInfoListHtml(context, hqlList, hqlOld,20); 
	    	
		    //重新生成分页静态页面结束
			
	        //生成首页静态页面,每页八条条
//		
//			this.createInfoIndex(context, hqlList,10);
			
			//生成滚动新闻,显示5张图片
//			if("news".equals(infoType)){
//				
//				infoType="scrollNews";
//				
//				String scrollNewsOld="from ImageInfo img where img.info.infoId in(select inf.infoId from Info inf where inf.infoType=2 and inf.auditing =2  )"+" order by imageId desc";
//				
//				String scrollNewsNew="from ImageInfo img where img.info.infoId in(select inf.infoId from Info inf where inf.infoType=2 and inf.auditing=2 and inf.infoId!="+id+")"+" order by imageId desc";
//				
//				this.createInfoListHtml(context, scrollNewsNew, scrollNewsOld, 5);
//				
////				this.createInfoIndex(context, scrollNewsNew, 5);
//				
//				infoType="news";
//			}

	        /////重新静态化首页
			this.creatIndex(context, 8);
			
		   String returnType = infoType +"DeleteInfoDetailHtml";
			
		   return  returnType;
	}
	
	
	/***
	 *  访问静态页面，阅读次数加一
	 * @throws Exception
	 */
	 
	public void ReadTimeAddOne() throws Exception{
		
	     HttpServletResponse res = ServletActionContext.getResponse();
		 
		 res.setCharacterEncoding("utf-8");
		 
		 res.setContentType("text/xml");
		 
		  int readTimes = 0;
		  
		  Info  info =(Info)this.getCommonService().findByIntId(id, "gdut.jmxywz.been.Info");
		  
	   	  //更新阅读次数，加一
	   	  readTimes =info.getInfoReadtimes()+1;
	   	  
	   	  info.setInfoReadtimes(info.getInfoReadtimes()+1);
	   	  
	   	  this.getCommonService().updateObject(info);
	   	  
		 
	   	  PrintWriter out = null;   
		  
	        try {   
	            out = res.getWriter();   
	            out.print("<root>");   
	            out.print("<message>");   
	            out.print(readTimes);   
	            out.print("</message>");   
	            out.print("</root>");   
	        } catch (Exception e) {   
	            e.printStackTrace();   
	        } finally {   
	            out.flush();   
	            out.close();   
	        }   
	}
	/***
	 * 查询下载下载次数
	 * TableDownLoadTimes
	 */
   public void TableDownLoadTimes()throws Exception{
	   
	   HttpServletResponse res = ServletActionContext.getResponse();
		 
		 res.setCharacterEncoding("utf-8");
		 
		 res.setContentType("text/xml");
		 
		  int readTimes = 0;
		  if("0".endsWith(infoType)){
			  
			  TableFiles  tableFiles =(TableFiles)this.getCommonService().findByIntId(id, "gdut.jmxywz.been.TableFiles");
			  
		   	  readTimes =tableFiles.getDownloadTime();
		   	  
		  }else if("1".equals(infoType)){
			  TeachingFiles teachingFiles = (TeachingFiles)this.getCommonService().findByIntId(id, "gdut.jmxywz.been.TeachingFiles");
		   	  
			  readTimes =teachingFiles.getDownloadtime();
		  }
	   	
	   	  PrintWriter out = null;   
		  
	        try {   
	            out = res.getWriter();   
	            out.print("<root>");   
	            out.print("<message>");   
	            out.print(readTimes);   
	            out.print("</message>");   
	            out.print("</root>");   
	        } catch (Exception e) {   
	            e.printStackTrace();   
	        } finally {   
	            out.flush();   
	            out.close();   
	        }   
   }
	
	
	/***
	 *  静态化通知公告消息列表
	 * @return
	 */
	public String InfoListHtml(){
		
		String hql ="";
		
        if("tableFiles".equals(infoType)||"teachingFiles".endsWith(infoType)){
			   
			   if("tableFiles".equals(infoType)){
				   hql="from TableFiles where auditing = 2 ";
				   
			   }else{
				   hql="from TeachingFiles where auditing = 2 ";
			   }
		   }else{
			   
			hql="from Info where auditing = 2 and infoType = "+infoType;
		   }
		
		Map <String ,Object> data = new HashMap<String , Object>();
		
		ServletContext  context = ServletActionContext.getServletContext();
			
		List infoList = this.getCommonService().findListByHql(hql, null);
		  
		System.out.println("---"+context.getRealPath("/"));
			
		data.put("infoList",infoList);
		   
			//tld，存放ftl模板的路径以，ftl/ 信息类型/信息类型.ftl ,存放
			String templatePath="ftl/"+infoType+"/"+infoType+"List"+".ftl";
			
			//生成的静态页面名称，以信息类型+List组成
			String targetHtmlPath="htmlPage"+"/"+infoType+"/"+infoType+"List"+".html";
			
			this.getCommonService().createHtml(context, data, templatePath, targetHtmlPath);
		
		
		return "InfoListHtml";
	}

	
	/***
	 * 生成单个Info详细内容静态页面
	 * @param context
	 * @param id
	 * @param fileHql
	 */
	public void createInfoDetail(ServletContext context,int id,String fileHql){
		
		   Map <String ,Object> data = new HashMap<String , Object>();
		   String targetHtmlPath = "";
		   data.put("infoType", infoType);
           if("tableFiles".equals(infoType)||"teachingFiles".equals(infoType)){
			   
			   if("tableFiles".equals(infoType)){
				   
				   TableFiles tableFiles=(TableFiles)this.getCommonService().findByIntId(id, "gdut.jmxywz.been.TableFiles");
		  	       
				   data.put("tableFiles", tableFiles);
				   
				   //生成的静态页面名称，以信息类型+信息Id组成
				    targetHtmlPath="htmlPage"+"/"+infoType+"/"+infoType+tableFiles.getTableId()+".html";
				    
			   }else{
				   TeachingFiles teachingFiles=(TeachingFiles)this.getCommonService().findByIntId(id, "gdut.jmxywz.been.TeachingFiles");
				   
				   data.put("teachingFiles", teachingFiles);
				   //生成的静态页面名称，以信息类型+信息Id组成
				    targetHtmlPath="htmlPage"+"/"+infoType+"/"+infoType+teachingFiles.getTeachSrcId()+".html";
				    
			   }
		   }else{
		   
			Info   info1 = (Info)this.getCommonService().findByIntId(id, "gdut.jmxywz.been.Info");
		   
			List   infoFiles = this.getCommonService().findListByHql(fileHql, null);
		   
		    data.put("info",info1);
		    data.put("infoFiles", infoFiles);
		    
		  //生成的静态页面名称，以信息类型+信息Id组成
		    targetHtmlPath="htmlPage"+"/"+infoType+"/"+infoType+info1.getInfoId()+".html";
		    
		   }
	
           //生成滚动新闻,显示5张图片
//			if("news".equals(infoType)){
//				
//				infoType="scrollNews";
//				
//				String scrollNews="from ImageInfo img where img.info.infoId in(select inf.infoId from Info inf where inf.auditing =2)"+" order by imageId desc";
//				
////				//列表more
//				this.createInfoListHtml(context, scrollNews, "", 5);
////				//主页
////				this.createInfoIndex(context, scrollNews, 5);
//				
//				infoType="news";
//			}
           
		   System.out.println("---"+context.getRealPath("/"));
		   
			//tld，存放ftl模板的路径以，ftl/ 信息类型/信息类型.ftl ,存放
		   String templatePath="ftl/"+infoType+"/"+infoType+".ftl";
			
		 this.getCommonService().createHtml(context, data, templatePath, targetHtmlPath);
		
	}
	
	/***
	 * 创建主页各Info静态页面
	 * @param context
	 * @param hqlList
	 * @param pageSize
	 */
//	 
//	public void createInfoIndex(ServletContext context,String hqlList,int pageSize){
//		
//	     
//	    //生成一个InfotypeIndex页面。
//		
//		Map <String ,Object> indexData = new HashMap<String , Object>();
//		
//		String indexTemple ="ftl/"+infoType+"/"+infoType+"Index.ftl";
//		
//		String indexHtmlPath = "htmlPage"+"/"+"index"+"/"+"/"+infoType+"Index.html";
//		
//		PageModel pageModel = this.getCommonService().findPage(hqlList, null, 1, pageSize, "", "");
//		
//		System.out.println("+++++++++++++++++++++++++++++++++"+pageModel.getList().size());
//		
//		indexData.put("indexInfo", pageModel.getList());
//		
//		indexData.put("infoType",infoType);
//		
//	   this.getCommonService().createHtml(context, indexData, indexTemple, indexHtmlPath);
//			
//	}
	/***
	 * 创建消息列表分页静态页面
	 * @param context
	 * @param hqlList
	 * @param hqlOld
	 */
	public void createInfoListHtml(ServletContext context,String hqlList,String hqlOld,int pageSize){
		
		int  currentPage = 1;
   	    int  totalHtmlPage = 0;
   	    int  totalHtmlPageOld =-1;
   	    PageModel pm = new PageModel();
   	    Map <String ,Object> data = new HashMap<String , Object>();
   	   
   	   List infoList = this.getCommonService().findListByHql(hqlList, null);
   	   
   	   List infoListOld = new ArrayList();
   	   
   	   if(!"".equals(hqlOld)){
   	   	     infoListOld = this.getCommonService().findListByHql(hqlOld, null);
   	   	     totalHtmlPageOld = infoListOld.size()/pageSize;
   	     }

   	   totalHtmlPage = infoList.size()/pageSize;
   	   
	   if(infoList.size()%pageSize!=0){
			totalHtmlPage =totalHtmlPage+1;
	  	}
   	   if(infoListOld.size()%pageSize!=0){
			totalHtmlPageOld =totalHtmlPage+1;
		}
	 
	    //先删除服务器的所有静态分页
	   	if(totalHtmlPageOld==0){
			totalHtmlPageOld=1;
		}
		while(totalHtmlPageOld>0){
			
			String listPath ="htmlPage"+"/"+infoType+"/"+infoType+"List"+totalHtmlPageOld+".html";
			
			
			if(this.getCommonService().fileExist(listPath)){
				
				//删除静态化文件，
				this.getCommonService().fileDelete(listPath);
				
				System.out.println("已删除旧的staticHtmlList---"+listPath);
			}
			
			totalHtmlPageOld--;
	  	}
		
		System.out.println("-----------totalHtmlPage--------------------"+totalHtmlPage);
		//生成新的静态页面
		if(totalHtmlPage==0){
			totalHtmlPage=1;
		}
		while(totalHtmlPage>0){
			
			System.out.println("totalHtmlPage----"+totalHtmlPage);
			
			System.out.println("currentPage---"+currentPage);
			
			pm = this.getCommonService().findHtmlPage(hqlList, currentPage, infoType, pageSize);
			
	        data.put("infoList", pm.getList());
			data.put("infoType", infoType);
			data.put("pageMessage",pm.getPageMessage());
			       
		   //tld，存放ftl模板的路径以，ftl/ 信息类型/信息类型.ftl ,存放
		    	 
		   String templatePath2="ftl/"+infoType+"/"+infoType+"List"+".ftl";
					
		  //生成的静态页面名称，以信息类型+List组成
					
		   String targetHtmlPath2="htmlPage"+"/"+infoType+"/"+infoType+"List"+currentPage+".html";
					
	       this.getCommonService().createHtml(context, data, templatePath2, targetHtmlPath2);
				  
		   currentPage++;
				  
		   totalHtmlPage--;
				  
	   	 }
	}
	
	
	
	
	/***
	 * 创建静态化首页 （改）
	 * @param context
	 * @param pageSize
	 */
    public void creatIndex(ServletContext context,int pageSize){
    	
    	String afficheHql = "from Info where auditing=2 and infoType =1 order by infoTime desc,infoId desc";
    	String newsHql ="from Info where auditing=2 and infoType =2 order by infoTime desc,infoId desc ";
    	String scrollNewsHql = "from ImageInfo iminfo where iminfo.info.auditing=2 order by imageId desc";
    	String scientificHql = "from Info where auditing=2 and infoType =3 order by infoTime desc,infoId desc ";
    	String dynamicHql = "from Info where auditing=2 and infoType =4 order by infoTime desc,infoId desc ";
    	//
    	String parttyconstructionstudentAffairsHql = "from Info where auditing=2 and infoType =5 order by infoTime desc,infoId desc";
    	String studentunionstudentAffairsHql = "from Info where auditing=2 and infoType =9 order by infoTime desc,infoId desc";
    	String youncommitmentstudentAffairsHql = "from Info where auditing=2 and infoType =10 order by infoTime desc,infoId desc";
    	String mentalystudentAffairsHql = "from Info where auditing=2 and infoType =11 order by infoTime desc,infoId desc";
    	String granduatestudentAffairsHql = "from Info where auditing=2 and infoType =12 order by infoTime desc,infoId desc";
    	String jobstudentAffairsHql = "from Info where auditing=2 and infoType =13 order by infoTime desc,infoId desc";
    	//
    	String tableFileHql = "from TableFiles where auditing = 1 order by uploadTime desc, tableId desc";
    	String prizeHql="from Prize where auditing=2 order by prizeId desc";
    	String bookmakingHql="from Bookmaking where auditing=2 order by bookmakingId desc";
    	String dissertationHql="from Dissertation where auditing=2 order by disId desc";
    	
	    Map <String ,Object> indexData = new HashMap<String , Object>();
		
		String indexTemple ="ftl/"+"index.ftl";
		
		String indexHtmlPath ="index.html";
		
    	
    	//生成通知公告affiche区
    	PageModel affichePm = this.getCommonService().findPage(afficheHql, null, 1, pageSize, "", "");
    	//新闻区
    	PageModel newsPm = this.getCommonService().findPage(newsHql, null, 1, pageSize, "", "");
    	//滚动新闻区
    	PageModel scrollNewsPm = this.getCommonService().findPage(scrollNewsHql, null, 1, 5, "", "");
    	
    	//
    	//学生工作区(学生党建)
    	PageModel parttyconstructionstudentAffairsPm = this.getCommonService().findPage(parttyconstructionstudentAffairsHql, null, 1, 5, "", "");
    	//学生工作区(院学生会)
    	PageModel studentunionstudentAffairsPm = this.getCommonService().findPage(studentunionstudentAffairsHql, null, 1, 5, "", "");
    	//学生工作区(学生团委)
    	PageModel youncommitmentstudentAffairsPm = this.getCommonService().findPage(youncommitmentstudentAffairsHql, null, 1, 5, "", "");
    	//学生工作区(心悦心理协会)
    	PageModel mentalystudentAffairsPm = this.getCommonService().findPage(mentalystudentAffairsHql, null, 1, 5, "", "");
    	//学生工作区(毕业生通知)
    	PageModel granduatestudentAffairsPm = this.getCommonService().findPage(granduatestudentAffairsHql, null, 1, 5, "", "");
    	//学生工作区(就业资讯)
    	PageModel jobstudentAffairsPm = this.getCommonService().findPage(jobstudentAffairsHql, null, 1, 5, "", "");
    	
    	//
    	
    	//科研信息区
    	PageModel scientificPm = this.getCommonService().findPage(scientificHql, null, 1, 7, "", "");
    	//科研动态区
    	PageModel dynamicPm = this.getCommonService().findPage(dynamicHql, null, 1, 5, "", "");
    	//表格下载区
//    	PageModel tableFilePm= this.getCommonService().findPage(tableFileHql, null, 1, 5, "", "");
    	//科研或奖
    	PageModel prize   =this.getCommonService().findPage(prizeHql, null, 1, 5, "", "");
    	//科研论文
    	PageModel bookmaking   =this.getCommonService().findPage(bookmakingHql, null, 1, 5, "", "");
    	//科研著作
    	PageModel dissertation  =this.getCommonService().findPage(dissertationHql, null, 1, 5, "", "");

    	System.out.println("------dd----"+dissertation.getList().size());
    	//图片地址字符串
        String imgUrl="";
        String imgLink="";
        //图片的新闻标题
        String newssolltitle="";
    	List<ImageInfo> imageInfo = scrollNewsPm.getList();
    	int j=0;
        for(ImageInfo img:imageInfo){
        	j++;
        	
        	if(j==5){
        		imgUrl = imgUrl+img.getImageUrl();
            	imgLink =imgLink+"htmlPage/news/news"+img.getInfo().getInfoId()+".html";
            	newssolltitle=img.getInfo().getInfoTitle();
        	}else{
        		imgUrl = imgUrl+img.getImageUrl()+"|";
            	imgLink =imgLink+"htmlPage/news/news"+img.getInfo().getInfoId()+".html|";
            	newssolltitle=img.getInfo().getInfoTitle();
        	}
        }
    	
    	
    	//装入indexData
    	indexData.put("affiche", affichePm.getList());
    	indexData.put("news", newsPm.getList());
//    	indexData.put("scrollNews", scrollNewsPm.getList());
    	indexData.put("imgUrl", imgUrl);
    	indexData.put("imgLink", imgLink);
    	indexData.put("newssolltitle", newssolltitle);
    	
    	//新加入的
    	indexData.put("parttyconstructionstudentAffairs", parttyconstructionstudentAffairsPm.getList());
    	indexData.put("studentunionstudentAffairs", studentunionstudentAffairsPm.getList());
    	indexData.put("youncommitmentstudentAffairs", youncommitmentstudentAffairsPm.getList());
    	indexData.put("mentalystudentAffairs", mentalystudentAffairsPm.getList());
    	indexData.put("granduatestudentAffairs", granduatestudentAffairsPm.getList());
    	indexData.put("jobstudentAffairs", jobstudentAffairsPm.getList());
    	
    	//
    	indexData.put("scientific", scientificPm.getList());
    	indexData.put("dynamic", dynamicPm.getList());
    	indexData.put("prize", prize.getList());
    	indexData.put("bookmaking", bookmaking.getList());
    	indexData.put("dissertation", dissertation.getList());
//    	indexData.put("tableFiles",tableFilePm.getList());
    	
    	
    	//开始静态化
    	System.out.println("-----------静态化首页开始--------");
    	
    	this.getCommonService().createHtml(context, indexData, indexTemple, indexHtmlPath);
    	
    	System.out.println("-----------静态化首页完成--------");
    	
    }	
    
    
    
    
    //静态化所有已经审核为院外的info
    
    public String staticAllInfo()throws Exception{
    	
    	ServletContext  context = ServletActionContext.getServletContext();
    	
    	String hql ="";
    	
    	String hql1="";
    	
    	String hql2="";
    	
    	int  temp =-1;
    	
    	if("1".equals(this.infoType)){
    	
    		hql = "from Info where auditing = 2 and infoType= "+this.infoType+" order by infoTime desc , infoId desc";
    		
		    //通知公告
			 this.infoType="affiche";
			
			 temp=0;
			 
		   }else if("2".equals(this.infoType)){
			 //学院新闻
			    hql = "from Info where auditing = 2 and infoType= "+this.infoType+" order by infoTime desc , infoId desc";
	    		
			   this.infoType="news";
			   
			   temp=0;
			   System.out.println("++++++enter+++++++++++++++");
		   }
		   else if("3".equals(this.infoType)){
			    //科研信息
			   hql = "from Info where auditing = 2 and infoType= "+this.infoType+" order by infoTime desc , infoId desc";
	    		
			   this.infoType="scientific";
			   
			   temp=0;
		   }
		   else if("4".equals(this.infoType)){
			    //科研动态
			    hql = "from Info where auditing = 2 and infoType= "+this.infoType+" order by infoTime desc , infoId desc";
	    		
			   this.infoType="dynamic";
			   
			   temp=0;
			   
		   }else if("5".equals(this.infoType)){
			    //学生党建工作
			    hql = "from Info where auditing = 2 and infoType= "+this.infoType+" order by infoTime desc , infoId desc";
	    		
			   
			   this.infoType="parttyconstructionstudentAffairs";
			   
			   temp=0;
			   
			  
			   
		   } else if("9".equals(this.infoType)){
			   //院学生会工作
			    hql = "from Info where auditing = 2 and infoType= "+this.infoType+" order by infoTime desc , infoId desc";
	    		
			   
			   this.infoType="studentunionstudentAffairs";
			   
			   temp=0;
			   
			   
			  
		   }else if("10".equals(this.infoType)){
			   //学生团委工作
			    hql = "from Info where auditing = 2 and infoType= "+this.infoType+" order by infoTime desc , infoId desc";
	    		
			   
			   this.infoType="youncommitmentstudentAffairs";
			   
			   temp=0;
			   
			   
			  
		   }else if("11".equals(this.infoType)){
			   //心悦心理协会工作
			    hql = "from Info where auditing = 2 and infoType= "+this.infoType+" order by infoTime desc , infoId desc";
	    		
			   
			   this.infoType="mentalystudentAffairs";
			   
			   temp=0;
			   
			   
			  
		   }else if("12".equals(this.infoType)){
			   //毕业生通知工作
			    hql = "from Info where auditing = 2 and infoType= "+this.infoType+" order by infoTime desc , infoId desc";
	    		
			   
			   this.infoType="granduatestudentAffairs";
			   
			   temp=0;
			   
			   
			  
		   }else if("13".equals(this.infoType)){
			   //就业资讯工作
			    hql = "from Info where auditing = 2 and infoType= "+this.infoType+" order by infoTime desc , infoId desc";
	    		
			   
			   this.infoType="jobstudentAffairs";
			   
			   temp=0;
			   
			   
			  
		   }else if("6".equals(this.infoType)){
			   
			   //表格下载
			   hql1="from TableFiles where auditing = 1  order by uploadTime desc , tableId desc";
			   
			   this.infoType="tableFiles";
			   
			   temp=1;
			   
		   }else if("7".equals(this.infoType)){
			   //教学资源下载
			   
			   hql2="from TeachingFiles where auditing = 1  order by uploadTime desc , teachSrcId desc";
			   
			   this.infoType="teachingFiles";
			   
			   temp=2;
		   }else if("8".equals(this.infoType)){
			   //全部静态化
			   hql = "from Info where auditing = 2  order by infoTime desc , infoId desc";
			   hql1="from TableFiles where auditing = 1  order by uploadTime desc , tableId desc";
			   hql2="from TeachingFiles where auditing = 1  order by uploadTime desc , teachSrcId desc";
			   
			   temp=3;
		   }
    	
    	   if(temp==-1){
  		    
		  	return "staticAllInfo";
	       }
    	   if(temp==0||temp==3){
    		   
	    	List listAll =this.getCommonService().findListByHql(hql, null);
	    	
	    	Iterator iter = listAll.iterator();
	    	
	    	while(iter.hasNext()){
	    		
	    		   Info info = (Info)iter.next();
	    		
	    		   System.out.println("----------"+id);
	    		   
	    		   String fileHql="from InfoFiles where infoId = "+info.getInfoId();
	      	       
	    		   System.out.println("-----------静态化----------");
	    		   
	    		   this.infoType = info.getInfoType();
	    		   this.change();
	    		   
	    		   //创建单个静态化文件
	    		   this.createInfoDetail(context, info.getInfoId(), fileHql);
	    		  
	    	       System.out.println("-----------静态化列表2----------");
	    	    	 
	    	       
	    	       //生成滚动新闻,显示5张图片
	//    			if("news".equals(infoType)){
	//    				
	//    				infoType="scrollNews";
	//    				
	//    				String scrollNews="from ImageInfo img where img.info.infoId in(select inf.infoId from Info inf where inf.auditing = 2 )"+" order by imageId desc";
	//    				
	//    				System.out.println("--------hql------"+scrollNews);
	//    				
	////    				//主页
	////    				this.createInfoIndex(context, scrollNews, 10);
	//    				
	//    				infoType="news";
	//    			}
	    	       
	    	    	//生成静态化消息列表----分页生成显示多个html文件,没有10条
	     	}
	    	  this.createInfoListHtml(context, hql,"",20);
	    	 
 	       
    	   }
    	   //tableFiles
    	  if(temp==1||temp==3){
    		
    	    this.infoType="tableFiles";
    		 
    		List listAll =this.getCommonService().findListByHql(hql1, null);
  	    	
  	    	Iterator iter = listAll.iterator();
  	    	
  	    	while(iter.hasNext()){
  	    		
  	    		   TableFiles tableFiles = (TableFiles)iter.next();
  	    		   
  	    		   //创建单个静态化文件
  	    		   this.createInfoDetail(context,tableFiles.getTableId() , "");
  	    		  
  	    	       System.out.println("-----------TableFiles静态化列表完成----------");
  	    	    	 
  	    	}
  	    	//创建列表
  	    	 this.createInfoListHtml(context, hql1,"",20);
    	  } 
    	  //teachingFiles
    	  if(temp==2||temp==3){
    		 //当temp=3时，设置为teachingFiles
    		this.infoType="teachingFiles";
     		
    	    List listAll =this.getCommonService().findListByHql(hql2, null);
   	    	
   	    	Iterator iter = listAll.iterator();
   	    	
   	    	while(iter.hasNext()){
   	    		
   	    		   TeachingFiles teachingFiles = (TeachingFiles)iter.next();
   	    		   
   	    		   //创建单个静态化文件
   	    		   this.createInfoDetail(context,teachingFiles.getTeachSrcId() , "");
   	    		  
   	    	       System.out.println("-----------TeachingFiles静态化列表完成----------");
   	    	}
   	         //创建列表
 	    	 this.createInfoListHtml(context, hql2,"",20);
     	  }
    	   
    	 ///静态化首页
    	this.creatIndex(context, 8);
    	
    	return "staticAllInfo";
    }
    
    /***科研获奖
     * 
     * * @return
     * @throws Exception
     */
    public String StaticPrize()throws Exception{
    	
    	 infoType="prize";
    	//先创建单个静态化，在创建静态化列表
    	 ServletContext  context = ServletActionContext.getServletContext();
		  
    	  Map <String ,Object> data = new HashMap<String , Object>();
    	  
    	  String templatePath ="/ftl/prize/prize.ftl";
    	  String targetHtmlPath="htmlPage/prize"+"/prize"+id+".html";
    	  String hqlList = "from Prize where auditing=2 order by prizeId desc";
    	  
//    	  Prize prize =null;//(Prize)this.getCommonService().findByIntId(id,"gdut.jmxywz.been.Prize");
//    	  
//    	  data.put("prize", prize);
//    	  
//    	 //静态化单个文件 
//          this.getCommonService().createHtml(context, data, templatePath, targetHtmlPath);
//  		
         //静态化文件列表
         //生成静态化消息列表----分页生成显示多个html文件,每个10条
    	 
	       this.createInfoListHtml(context, hqlList,"",20);
	     
    	return "staticPrize";
    }
    /***
     * 删除科研获奖静态页。
     * @return
     * @throws Exception
     */
    public String DeleteStaticPrize()throws Exception{
   	  infoType="prize";
      ServletContext  context = ServletActionContext.getServletContext();
      
      String hqlList="from Prize where auditing=2 order by prizeId desc";
      String hqlOld="from Prize where auditing=2 order by prizeId desc";  
      
//      String path ="htmlPage"+"/prize/prize"+id+".html";
//		
//		if(this.getCommonService().fileExist(path)){
//			
//			//删除静态化文件，
//			this.getCommonService().fileDelete(path);
//			
//			System.out.println("已删除staticHtml---"+path);
//		}
		
  	    //生成静态化消息列表----分页生成显示多个html文件,每页20条
		System.out.println("----"+hqlList);
		System.out.println("----"+hqlOld);
  
		this.createInfoListHtml(context, hqlList, hqlOld,20); 
		
    	return "deleteStaticPrize";
    }
    
    /****
     * 静态化所有记录，包括:1:科研获奖，
     * @return
     * @throws Exception
     */
    
    public String StaticHtmlOfPrize() throws Exception{
      	
    	infoType="prize";
    	//先创建单个静态化，在创建静态化列表
   	  ServletContext  context = ServletActionContext.getServletContext();
		  
   	  Map <String ,Object> data = new HashMap<String , Object>();
   	  
   	  String templatePath ="ftl/"+infoType+"/"+infoType+".ftl";
   	  
   	  String targetHtmlPath="";
   	  
   	  String hqlList = "from Prize where auditing=2 order by prizeId desc";
   	  
   	  List list = this.getCommonService().findListByHql(hqlList, null);
   	  
   	  Iterator iter = list.iterator();
   	  if(!iter.hasNext()){
   		targetHtmlPath="htmlPage/"+infoType+"/"+infoType+"1"+".html";
//   	    this.getCommonService().createHtml(context, data, templatePath, targetHtmlPath);
   	    this.createInfoListHtml(context, hqlList,hqlList,20);
   	  }
   	  while(iter.hasNext()){
   		  
   		Prize prize = (Prize)iter.next();
   		
   		targetHtmlPath="htmlPage/"+infoType+"/"+infoType+prize.getPrizeId()+".html";
	 
	   	  data.put("prize",prize);
	   	
	   	   //静态化单个文件 
	      this.getCommonService().createHtml(context, data, templatePath, targetHtmlPath);
 		
   	  }
        //静态化文件列表
        //生成静态化消息列表----分页生成显示多个html文件,每个10条
   	 
	    this.createInfoListHtml(context, hqlList,"",20);

    	return "staticHtmlOfPrize";
    }
    /***
     * 科研著作
     * @return
     * @throws Exception
     */
    public String StaticBookmaking()throws Exception{
    	
    	infoType="bookmaking";
    	//先创建单个静态化，在创建静态化列表
   	  ServletContext  context = ServletActionContext.getServletContext();
		  
   	  Map <String ,Object> data = new HashMap<String , Object>();
   	  
   	  String templatePath ="ftl/bookmaking/bookmaking.ftl";
   	  String targetHtmlPath="htmlPage/bookmaking"+"/bookmaking"+id+".html";
   	  String hqlList = "from Bookmaking where auditing=2 order by bookmakingId desc";
   	  
   	  String hqlfile = "from BookmakingFile bmf where bmf.bookmaking.bookmakingId="+id;
   	  
//   	  Bookmaking bookmaking = (Bookmaking)this.getCommonService().findByIntId(id, "gdut.jmxywz.been.Bookmaking");
   	  
   	  //查找附件
      List bookmakingfile = this.getCommonService().findListByHql(hqlfile, null);
      
//   	  data.put("bookmaking",bookmaking);
//   	
//   	  data.put("bookmakingfile",bookmakingfile);
//   	   //静态化单个文件 
//      this.getCommonService().createHtml(context, data, templatePath, targetHtmlPath);
// 		
        //静态化文件列表
        //生成静态化消息列表----分页生成显示多个html文件,每个10条
   	 
	    this.createInfoListHtml(context, hqlList,hqlList,20);
	    
	    //静态化首页。
	    this.creatIndex(context, 8);    	
	    
    	return "staticBookmaking";
    }
    
    /***
     * 删除科研著作
     * @return
     * @throws Exception
     */
    public String DeleteStaticBookmaking()throws Exception{
    	
  	  infoType="bookmaking";
  	  
      ServletContext  context = ServletActionContext.getServletContext();
      
      String hqlList="from Bookmaking where auditing=2 order by bookmakingId desc";
      
      String hqlOld="from Bookmaking where auditing=2 order by bookmakingId desc";
      
//      String path ="htmlPage"+"/bookmaking/bookmaking"+id+".html";
		
//		if(this.getCommonService().fileExist(path)){
//			
//			//删除静态化文件，
//			this.getCommonService().fileDelete(path);
//			
//			System.out.println("已删除staticHtml---"+path);
//		}
		
  	    //生成静态化消息列表----分页生成显示多个html文件,每页20条
//		System.out.println("----"+hqlList);
//		System.out.println("----"+hqlOld);
//  
		this.createInfoListHtml(context, hqlList, hqlOld,20); 
    	
	    //静态化首页。
	    this.creatIndex(context, 8);    	
	    
		
    	return "deleteStaticBookmaking";
    }
    /****
     * 静态化所有记录，包括2:科研著作
     * @return
     * @throws Exception
     */
    
    public String StaticHtmlOfBookmaking() throws Exception{
      	
    	infoType="bookmaking";
    	//先创建单个静态化，在创建静态化列表、、只生成静态化列表。
   	  ServletContext  context = ServletActionContext.getServletContext();
		  
   	  Map <String ,Object> data = new HashMap<String , Object>();
   	  
//   	  String templatePath ="ftl/"+infoType+"/"+infoType+".ftl";
//   	  
//   	  String targetHtmlPath="";
   	  
   	  String hqlList = "from Bookmaking where auditing=2 order by bookmakingId desc";
   	  
   	  List list = this.getCommonService().findListByHql(hqlList, null);
   	  
   	  Iterator iter = list.iterator();
   	  if(!iter.hasNext()){
   	    this.createInfoListHtml(context, hqlList,"",20);
   	  }
//   	  while(iter.hasNext()){
//   		  
//   		Bookmaking bookmaking = (Bookmaking)iter.next();
//   		
//   		targetHtmlPath="htmlPage/"+infoType+"/"+infoType+bookmaking.getBookmakingId()+".html";
//	 
//   		String hqlfile = "from BookmakingFile bmf where bmf.bookmaking.bookmakingId="+bookmaking.getBookmakingId();
//   	  
//	   	  //查找附件
//	      List bookmakingfile = this.getCommonService().findListByHql(hqlfile, null);
//	      
//	   	  data.put("bookmaking",bookmaking);
//	   	
//	   	  data.put("bookmakingfile",bookmakingfile);
//	   	   //静态化单个文件 
////	      this.getCommonService().createHtml(context, data, templatePath, targetHtmlPath);
// 		
//   	  }
//        //静态化文件列表
//        //生成静态化消息列表----分页生成显示多个html文件,每个10条
//   	 
	    this.createInfoListHtml(context, hqlList,"",20);

	    //静态化首页。
	    this.creatIndex(context, 8);    	
	    
    	return "staticHtmlOfBookmaking";
    }
    
    /***
     * 科研论文静态化
     * @return
     * @throws Exception
     */
    public String StaticDissertation()throws Exception{
    	infoType="dissertation";
    	//先创建单个静态化，在创建静态化列表
   	  ServletContext  context = ServletActionContext.getServletContext();
		  
   	  Map <String ,Object> data = new HashMap<String , Object>();
   	  
   	  String templatePath ="ftl/dissertation/dissertation.ftl";
   	  String targetHtmlPath="htmlPage/dissertation/dissertation"+id+".html";
   	  String hqlList = "from Dissertation where auditing=2 order by disId desc ";
   	  String hqlfile = "from DissertationFile df where df.dissertation.disId="+id;
   	  
   	  
   	  Dissertation dissertation = (Dissertation)this.getCommonService().findByIntId(id, "gdut.jmxywz.been.Dissertation");
   	  List dissertationfile =this.getCommonService().findListByHql(hqlfile, null);
   	  
   	  data.put("dissertation",dissertation);
   	  data.put("dissertationfile",dissertationfile);
   	  
   	   //静态化单个文件 
      this.getCommonService().createHtml(context, data, templatePath, targetHtmlPath);
 		
        //静态化文件列表
        //生成静态化消息列表----分页生成显示多个html文件,每个10条
   	 
	   this.createInfoListHtml(context, hqlList,"",20);
    	
	    //静态化首页。
	    this.creatIndex(context, 8);    	
	    
    	
    	return "staticDissertation";
    }
    /***
     * 删除科研论文
     * @return
     * @throws Exception
     */
    public String DeleteStaticDissertation()throws Exception{
    	
  	  infoType="dissertation";
  	  
      ServletContext  context = ServletActionContext.getServletContext();
      
      String hqlList="from Dissertation where auditing=2 order by disId desc ";
      
      String hqlOld="from Dissertation where auditing=2 order by disId desc ";
      
      String path ="htmlPage"+"/dissertation/dissertation"+id+".html";
		
		if(this.getCommonService().fileExist(path)){
			
			//删除静态化文件，
			this.getCommonService().fileDelete(path);
			
			System.out.println("已删除staticHtml---"+path);
		}
		
  	    //生成静态化消息列表----分页生成显示多个html文件,每页20条
		System.out.println("----"+hqlList);
		System.out.println("----"+hqlOld);
  
		this.createInfoListHtml(context, hqlList, hqlOld,20); 
	    //静态化首页。
	    this.creatIndex(context, 8);    	
	    
    	return "deleteStaticDissertation";
    }
    
    /****
     * 静态化所有记录，包括:3：科研论文
     * @return
     * @throws Exception
     */
    
    public String StaticHtmlOfDissertation() throws Exception{
      	
    	infoType="dissertation";
    	//先创建单个静态化，在创建静态化列表
   	  ServletContext  context = ServletActionContext.getServletContext();
		  
   	  Map <String ,Object> data = new HashMap<String , Object>();
   	  
   	  String templatePath ="ftl/"+infoType+"/"+infoType+".ftl";
   	  
   	  String targetHtmlPath="";
   	  
   	  String hqlList = "from Dissertation where auditing=2 order by disId desc ";
   	  
   	  List list = this.getCommonService().findListByHql(hqlList, null);
   	  
   	  Iterator iter = list.iterator();
   	  if(!iter.hasNext()){
   	    this.createInfoListHtml(context, hqlList,"",20);
   	  }
   	  while(iter.hasNext()){
   		  
   		Dissertation dissertation = (Dissertation)iter.next();
   		
   		targetHtmlPath="htmlPage/"+infoType+"/"+infoType+dissertation.getDisId()+".html";
	 
   		String hqlfile ="from DissertationFile df where df.dissertation.disId="+dissertation.getDisId();
   	  
	   	  //查找附件
	      List dissertationfile = this.getCommonService().findListByHql(hqlfile, null);
	      
	   	  data.put("dissertation",dissertation);
	   	
	   	  data.put("dissertationfile",dissertationfile);
	   	   //静态化单个文件 
	      this.getCommonService().createHtml(context, data, templatePath, targetHtmlPath);
 		
   	  }
        //静态化文件列表
        //生成静态化消息列表----分页生成显示多个html文件,每个10条
   	 
	    this.createInfoListHtml(context, hqlList,"",20);
	    //静态化首页。
	    this.creatIndex(context, 8);    	
	    
    	
    	return "staticHtmlOfDissertation";
    }
    
    
    /***
     * 横向项目静态化
     * @return
     * @throws Exception
     */
	public String StaticHorizontal()throws Exception{
		
		infoType="horizontal";
    	//先创建单个静态化，在创建静态化列表
   	  ServletContext  context = ServletActionContext.getServletContext();
		  
   	  Map <String ,Object> data = new HashMap<String , Object>();
   	  
   	  String templatePath ="ftl/horizontal/horizontal.ftl";
   	  String targetHtmlPath="htmlPage/horizontal/horizontal"+id+".html";
   	  String hqlList = "from Horizontal where auditing=2 order by horId desc ";
   	  String hqlfile="from HorizontalFile hzf where hzf.horizontal.horId="+id;
   	  
//      Horizontal horizontal = (Horizontal)this.getCommonService().findByIntId(id, "gdut.jmxywz.been.Horizontal");
   	 //查找附件
//      List horizontalfile = this.getCommonService().findListByHql(hqlfile, null);
//      
//      data.put("horizontalfile", horizontalfile);
//      
//   	  data.put("horizontal",horizontal);
//   	  
//   	   //静态化单个文件 
//      this.getCommonService().createHtml(context, data, templatePath, targetHtmlPath);
 		
        //静态化文件列表
        //生成静态化消息列表----分页生成显示多个html文件,每个10条
   	 
	    this.createInfoListHtml(context, hqlList,"",20);
	    //静态化首页。
	    this.creatIndex(context, 8);    	
	    
		return "staticHorizontal";
	}
    /***
     * 删除横向项目
     * @return
     * @throws Exception
     */
    public String DeleteStaticHorizontal()throws Exception{
    	
  	  infoType="horizontal";
  	  
      ServletContext  context = ServletActionContext.getServletContext();
      
      String hqlList= "from Horizontal where auditing=2 order by horId desc ";
      
      String hqlOld= "from Horizontal where auditing=2 order by horId desc ";
      
//      String path ="htmlPage"+"/horizontal/horizontal"+id+".html";
		
//		if(this.getCommonService().fileExist(path)){
//			
//			//删除静态化文件，
//			this.getCommonService().fileDelete(path);
//			
//			System.out.println("已删除staticHtml---"+path);
//		}
		
  	    //生成静态化消息列表----分页生成显示多个html文件,每页20条
		System.out.println("----"+hqlList);
		System.out.println("----"+hqlOld);
  
		this.createInfoListHtml(context, hqlList, hqlOld,20); 
		
	    //静态化首页。
	    this.creatIndex(context, 8);    	
	    
    	return "deleteStaticHorizontal";
    }
    
    /****
     * 静态化所有记录，4：横向项目
     * @return
     * @throws Exception
     */
    
    public String StaticHtmlOfHorizontal() throws Exception{
      	
    	infoType="horizontal";
    	//先创建单个静态化，在创建静态化列表
   	  ServletContext  context = ServletActionContext.getServletContext();
		  
   	  Map <String ,Object> data = new HashMap<String , Object>();
   	  
   	  String templatePath ="ftl/"+infoType+"/"+infoType+".ftl";
   	  
   	  String targetHtmlPath="";
   	  
   	  String hqlList = "from Horizontal where auditing=2 order by horId desc ";
   	  
   	  List list = this.getCommonService().findListByHql(hqlList, null);
   	  
   	  Iterator iter = list.iterator();
   	  if(!iter.hasNext()){
   	    this.createInfoListHtml(context, hqlList,"",20);
   	  }
   	  while(iter.hasNext()){
   		  
   		Horizontal horizontal = (Horizontal)iter.next();
   		
   		targetHtmlPath="htmlPage/"+infoType+"/"+infoType+horizontal.getHorId()+".html";
	 
   		String hqlfile ="from HorizontalFile hzf where hzf.horizontal.horId="+horizontal.getHorId();
   	  
	   	  //查找附件
	      List horizontalfile = this.getCommonService().findListByHql(hqlfile, null);
	      
	   	  data.put("horizontal",horizontal);
	   	
	   	  data.put("horizontalfile",horizontalfile);
	   	   //静态化单个文件 
//	      this.getCommonService().createHtml(context, data, templatePath, targetHtmlPath);
 		
   	  }
        //静态化文件列表
        //生成静态化消息列表----分页生成显示多个html文件,每个10条
	    this.createInfoListHtml(context, hqlList,"",20);
	      //静态化首页。
		this.creatIndex(context, 8);
		
    	return "staticHtmlOfHorizontal";
    }
    
	
	/***
	 * 纵向项目静态化
	 * @return
	 * @throws Exception
	 */
	public String  StaticVertical()throws Exception{
		
		infoType="vertical";
    	//先创建单个静态化，在创建静态化列表
   	  ServletContext  context = ServletActionContext.getServletContext();
		  
   
	 Map <String ,Object> data = new HashMap<String , Object>();
   	  
   	  String templatePath ="ftl/vertical/vertical.ftl";
   	  String targetHtmlPath="htmlPage/vertical/vertical"+id+".html";
   	  String hqlList = "from Vertical where auditing=2 order by verId desc ";
   	  String hqlfile ="from VerticalFile vf where vf.vertical.verId = "+id;
   	  
//      Vertical vertical = (Vertical)this.getCommonService().findByIntId(id, "gdut.jmxywz.been.Vertical");
   	  
//      List verticalfile =this.getCommonService().findListByHql(hqlfile, null);
//      
//   	  data.put("vertical",vertical);
//   	  data.put("verticalfile", verticalfile);
//   	   //静态化单个文件 
//      this.getCommonService().createHtml(context, data, templatePath, targetHtmlPath);
// 		
        //静态化文件列表
        //生成静态化消息列表----分页生成显示多个html文件,每个10条
   	 
	       this.createInfoListHtml(context, hqlList,"",20);
	       //静态化首页。
		    this.creatIndex(context, 8);    	
		    
		return "staticVertical";
	}
   /***
     * 删除纵向项目
     * @return
     * @throws Exception
     */
    public String DeleteStaticVertical()throws Exception{
    	
  	  infoType="vertical";
  	  
      ServletContext  context = ServletActionContext.getServletContext();
      
      String hqlList= "from Vertical where auditing=2 order by verId desc ";
      
      String hqlOld="from Horizontal where auditing=2 order by horId desc ";
      
      String path ="htmlPage"+"/vertical/vertical"+id+".html";
		
		if(this.getCommonService().fileExist(path)){
			
			//删除静态化文件，
			this.getCommonService().fileDelete(path);
			
			System.out.println("已删除staticHtml---"+path);
		}
		
  	    //生成静态化消息列表----分页生成显示多个html文件,每页20条
		System.out.println("----"+hqlList);
		System.out.println("----"+hqlOld);
  
		this.createInfoListHtml(context, hqlList, hqlOld,20); 
	    //静态化首页。
	    this.creatIndex(context, 8);    	
	    
    	return "deleteStaticVertical";
    }
    
    
    /****
     * 静态化所有记录，包括，5：纵向项目
     * @return
     * @throws Exception
     */
    
    public String StaticHtmlOfVertical() throws Exception{
      	
    	infoType="vertical";
    	//先创建单个静态化，在创建静态化列表
   	  ServletContext  context = ServletActionContext.getServletContext();
		  
   	  Map <String ,Object> data = new HashMap<String , Object>();
   	  
   	  String templatePath ="ftl/"+infoType+"/"+infoType+".ftl";
   	  
   	  String targetHtmlPath="";
   	  
   	  String hqlList =  "from Vertical where auditing=2 order by verId desc ";
   	  
   	  List list = this.getCommonService().findListByHql(hqlList, null);
   	  
   	  Iterator iter = list.iterator();
   	  if(!iter.hasNext()){
   	    this.createInfoListHtml(context, hqlList,"",20);
   	  }
   	  while(iter.hasNext()){
   		  
   		Vertical vertical = (Vertical)iter.next();
   		
   		targetHtmlPath="htmlPage/"+infoType+"/"+infoType+vertical.getVerId()+".html";
	 
   		String hqlfile ="from VerticalFile vf where vf.vertical.verId ="+vertical.getVerId();
   	  
	   	  //查找附件
	      List horizontalfile = this.getCommonService().findListByHql(hqlfile, null);
	      
	   	  data.put("vertical",vertical);
	   	
	   	  data.put("verticalfile",horizontalfile);
	   	   //静态化单个文件 
//	      this.getCommonService().createHtml(context, data, templatePath, targetHtmlPath);
 		
   	  }
        //静态化文件列表
        //生成静态化消息列表----分页生成显示多个html文件,每个10条
   	 
	    this.createInfoListHtml(context, hqlList,"",20);

	    //静态化首页。
	    this.creatIndex(context, 8);    	
	    
    	return "staticHtmlOfVertical";
    }
    
	/***
	 * 学生留言静态化
	 * @return
	 * @throws Exception
	 */
	public String StaticStudentBoard()throws Exception{
		
		infoType="studentBoard";
    	//先创建单个静态化，在创建静态化列表
   	  ServletContext  context = ServletActionContext.getServletContext();
		  
   	  Map <String ,Object> data = new HashMap<String , Object>();
   	  
   	  String templatePath ="ftl/studentBoard/studentBoard.ftl";
   	  String targetHtmlPath="htmlPage/studentBoard"+id+".html";
   	  String hqlList = "from StmessageBoard where auditing=2 order by messageBoardid desc ";
   	  
   	  int currentPage = 1;
   	  int pageSize = 10;
   	  
   	  String hql = "from StmessageReply  smr where smr.stmessageBoard.messageBoardid="+id;
   	  
   	  StmessageBoard studentBoard = (StmessageBoard)this.getCommonService().findByIntId(id, "gdut.jmxywz.been.StmessageBoard");
      
   	  PageModel strPm=(PageModel)this.getCommonService().findHtmlPage(hql, currentPage, infoType, pageSize);
   	  
   	  data.put("studentBoard",studentBoard);
   	  data.put("strPm", strPm.getList());
   	  
   	  
   	   //静态化单个文件 
      this.getCommonService().createHtml(context, data, templatePath, targetHtmlPath);
 		
        //静态化文件列表
        //生成静态化消息列表----分页生成显示多个html文件,每个10条
   	 
	     this.createInfoListHtml(context, hqlList,"",20);
    	
	  return "staticStudnetBoard";
	}
	/***
	 * 教师留言静态化
	 * @return
	 * @throws Exception
	 */
	public String StaticTeacherBoard()throws Exception{
		
		infoType="teacherBoard";
    	//先创建单个静态化，在创建静态化列表
   	  ServletContext  context = ServletActionContext.getServletContext();
		  
   	  Map <String ,Object> data = new HashMap<String , Object>();
   	  
   	  String templatePath ="ftl/messageBoard/messageBoard.ftl";
   	  String targetHtmlPath="htmlPage/messageBoard"+id+".html";
   	  String hqlList = "from MessageBoard where auditing=2 order by bookmakingId desc ";
   	  
      MessageBoard messageBoard = (MessageBoard)this.getCommonService().findByIntId(id, "gdut.jmxywz.been.MessageBoard");
   	  
   	  data.put("messageBoard",messageBoard);
   	  
   	   //静态化单个文件 
      this.getCommonService().createHtml(context, data, templatePath, targetHtmlPath);
 		
        //静态化文件列表
        //生成静态化消息列表----分页生成显示多个html文件,每个10条
   	 
	       this.createInfoListHtml(context, hqlList,"",20);
    	
		return "staticTeacherBoard";
	}
	
	
	
}


